using System;
using System.Data;
using System.Data.SqlClient;

using PHSRAG.Insight21.Admin;
using PHSRAG.Insight21.BusinessObjects;
using Utility = PHSRAG.Utility;
using ICachePolicy = PHSRAG.Insight21.Policy.ICachePolicy;

namespace PHSRAG.Insight21.ClinicalTrials
{
   /// <summary>
   /// The BudgetSummary class is the facade over a single Budget Summary
   /// </summary>
   public class BudgetSummary : BusinessObject
   {

      #region Constants
      private const string BudgetSummaryKey = "budgetSummary_E3128675-446C-4340-B8D1-D8709EFEBA5B";
      private const string TableName = "BudgetSummary";
      #endregion

      #region Instance Variables
      private DataRow dataRow;
      #endregion

      #region Constructor
      public BudgetSummary( ICachePolicy cachePolicy, DataRow row ) : base(cachePolicy)
      {
         dataRow = row;
      }
      #endregion

      /// <summary>
      /// Budget Id
      /// </summary>
      public int BudgetID
      {
			get 
         { 
            return (int)dataRow["Id"]; 
         }
      }

	   public int AccessRightBitmask
	   {
		   get 
		   { 
			   return (int)dataRow["AccessRightBitmask"]; 
		   }
	   }

      /// <summary>
      /// PI Name
      /// </summary>
      public string PIName
      {
         get
         {
            return dataRow["PIName"].ToString( );
         }
      }

      /// <summary>
      /// Originator Name
      /// </summary>
      public string OriginatorName
      {
         get
         {
            return dataRow["OriginatorName"].ToString( );
         }
      }

      /// <summary>
      /// Short Title
      /// </summary>
      public string ShortTitle
      {
         get
         {
            return dataRow["StudyShortTitle"].ToString( );
         }
      }

      /// <summary>
      /// Folder number
      /// </summary>
      public string FolderNumber
      {
         get
         {
            return dataRow["FolderNumber"].ToString( );
         }
      }

      /// <summary>
      /// Status
      /// </summary>
      public string Status
      {
         get
         {
            return dataRow["Status"].ToString( );
         }
      }

      public string SponsorName
      {
         get
         {
            return dataRow["SponsorName"].ToString( );
         }
      }

      /// <summary>
      /// Inserted Date
      /// </summary>
      public string InsertedDate
      {
         get
         {
            return ((DateTime)dataRow["InsertedDate"]).ToShortDateString( );
         }
      }

      /// <summary>
      /// Last Modified Date
      /// </summary>
      public string LastModifiedDate
      {
         get
         {
            return ((DateTime)dataRow["LastModifiedDate"]).ToShortDateString( );
         }
      }	

      /// <summary>
      /// Cache this instance using the prevalent cache policy.
      /// </summary>
      public override void Cache( )
      {
         CachePolicy.Cache( BudgetSummaryKey, this );
      }

      /// <summary>
      /// Remove this instance from the cache using the prevalent cache policy.
      /// </summary>
      public override void UnCache( )
      {
         CachePolicy.UnCache( BudgetSummaryKey );
      }

      /// <summary>
      /// Load method is not used
      /// </summary>
      /// <param name="connectionString"></param>
      /// <param name="args"></param>
      public override void Load( string connectionString, params object[] args )
      {
         throw new Exception("BudgetSummary is not directly loadable");
      }

   }// END CLASS DEFINITION BudgetSummary
}